// 房间相关类型
export interface Room {
  id: string;
  status: 'active' | 'expired' | 'closed';
  participantsCount: number;
  createdAt: string;
  expiresAt: string;
  maxParticipants: number;
}

// 参与者类型
export interface Participant {
  id: string;
  userId: string;
  roomId: string;
  joinedAt: string;
  status: 'connected' | 'disconnected';
}

// WebSocket 消息类型
export interface SocketMessage {
  type: string;
  data: any;
}

// 加入房间消息
export interface JoinRoomMessage extends SocketMessage {
  type: 'join-room';
  data: {
    roomId: string;
    userId: string;
  };
}

// 房间已加入消息
export interface RoomJoinedMessage extends SocketMessage {
  type: 'room-joined';
  data: {
    roomId: string;
    participants: string[];
  };
}

// WebRTC 信令消息
export interface OfferMessage extends SocketMessage {
  type: 'offer';
  data: {
    to: string;
    from: string;
    offer: RTCSessionDescriptionInit;
  };
}

export interface AnswerMessage extends SocketMessage {
  type: 'answer';
  data: {
    to: string;
    from: string;
    answer: RTCSessionDescriptionInit;
  };
}

export interface IceCandidateMessage extends SocketMessage {
  type: 'ice-candidate';
  data: {
    to: string;
    from: string;
    candidate: RTCIceCandidateInit;
  };
}

// 用户离开房间消息
export interface UserLeftMessage extends SocketMessage {
  type: 'user-left';
  data: {
    userId: string;
    roomId: string;
  };
}

// API 响应类型
export interface CreateRoomResponse {
  roomId: string;
  roomUrl: string;
  expiresAt: string;
}

export interface ApiError {
  message: string;
  statusCode: number;
  error?: string;
}

// 媒体设备状态
export interface MediaState {
  isVideoEnabled: boolean;
  isAudioEnabled: boolean;
  isScreenSharing: boolean;
}

// WebRTC 连接状态
export interface ConnectionState {
  isConnected: boolean;
  connectionState: RTCPeerConnectionState;
  iceConnectionState: RTCIceConnectionState;
}

// 房间设置
export interface RoomSettings {
  maxParticipants: number;
  allowScreenShare: boolean;
  allowChat: boolean;
  recordCall: boolean;
}

// 通话质量统计
export interface CallStats {
  duration: number; // 秒
  packetsLost: number;
  bytesReceived: number;
  bytesSent: number;
  frameRate: number;
  resolution: {
    width: number;
    height: number;
  };
}